package com.t18;

import nu.xom.Builder;
import nu.xom.Document;
import nu.xom.Elements;

import java.util.ArrayList;

/**
 * Created by xuyiwei on 2018/9/10.
 */
public class People extends ArrayList<Person>{
    public People(String fileName) throws Exception{
        Document document = new Builder().build(fileName);
        Elements elements = document.getRootElement().getChildElements();
        for(int i=0;i<elements.size();i++){
            add(new Person(elements.get(i)));
        }
    }

    public static void main(String[] args) throws Exception {
        People people = new People("/Users/xuyiwei/Documents/javaBase/jdk/People.xml");
        System.out.println(people);
        /**
         * [Dr. Bunsen Honeydew, Gonzo The Great, Phillip Fry]
         */
    }
}
